// MiniCC.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <cassert>
#include "Scanner.h"

using namespace std;

void test();

int main(int argc, char* argv[])
{

	Scanner scanner;

	scanner.scan();


	//test();

	return 0;
}



void testGetStateType(){
	Scanner s;
	assert(s.getStateType(0) == DEAD);
	assert(s.getStateType(1) != DEAD);
}

void testTable(){
	Scanner s;
	assert(s.getStateType(s.getNextState(0, 'a')) == DEAD);
	assert(s.getStateType(s.getNextState(0, '1')) == DEAD);
	assert(s.getStateType(s.getNextState(0, '.')) == DEAD);

	assert(s.getStateType(s.getNextState(0, '\0')) == DEAD);  // as EOF
}

void testGetCharType(){
	Scanner s;
	assert(s.getCharType('0') == DIGIT);
	assert(s.getCharType('3') == DIGIT);

	assert(s.getCharType('a') == LETTER);
	assert(s.getCharType('z') == LETTER);
	assert(s.getCharType('A') == LETTER);
	assert(s.getCharType('Z') == LETTER);

	assert(s.getCharType('*') == SYMBOL);
	assert(s.getCharType('/') == SYMBOL);

	assert(s.getCharType('.') == DOT);
	assert(s.getCharType('_') == UNDERLINE);

	assert(s.getCharType(' ') == UNKNOWN);

	assert(s.getCharType('\0') == END_OF_FILE);

}

void testGetNextState(){
	Scanner s;
	assert(s.getNextState(0, 'a') == 0);
	assert(s.getNextState(0, '1') == 0);
	assert(s.getNextState(0, '.') == 0);

	assert(s.getNextState(1, '1') == 2);
	assert(s.getNextState(2, '.') == 3);
	assert(s.getNextState(3, 'a') == 0);
	assert(s.getNextState(4, '9') == 4);
	assert(s.getNextState(5, '_') == 5);

	assert(s.getNextState(6, '2') == 0);
}

void test(){
	testGetStateType();
	testTable();
	testGetCharType();
	testGetNextState();
}